package com.huobao.yunying.activitys;

import java.util.Map;

import org.xutils.view.annotation.ViewInject;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.huobao.yunying.base.HuobaoBaseActivity;
import com.huobao.yunying.https.Http;
import com.huobao.yunying.https.HttpListener;
import com.huobao.yunying.https.HttpUtil;
import com.huobao.zhangying.R;

import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;

public class Act_gongao_detail extends HuobaoBaseActivity {

	@ViewInject(R.id.tv_title)
	private TextView tv_title;
	@ViewInject(R.id.tv_time)
	private TextView tv_time;
	@ViewInject(R.id.webview)
	private WebView webView;
	private String id;

	@Override
	protected int getContentView() {
		// TODO Auto-generated method stub
		return R.layout.layout_dongtai_detail;
	}

	@Override
	protected String getTitleText() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected void init() {
		mAbTitleBar.setVisibility(View.GONE);
		id = getIntent().getStringExtra("id");
		webView.getSettings().setJavaScriptEnabled(true);
		webView.getSettings().setUseWideViewPort(true);
		webView.getSettings().setLoadWithOverviewMode(true);
		getDetail();
	}

	private void getDetail() {
		Map<String, String> map = HttpUtil.getParams("app", "message", "act", "viewnotice", "nid", id);
		Http.getInstant().sendRequest(context, map, new HttpListener() {

			@Override
			public void onHttpSuccess(String result) {
				JSONObject jsonObject = JSON.parseObject(result);
				jsonObject = jsonObject.getJSONObject("retval");
				String title = jsonObject.getString("title");
				String content = jsonObject.getString("content");
				String add_time = jsonObject.getString("add_time");
				tv_title.setText(title);
				tv_time.setText(add_time);
				webView.loadDataWithBaseURL("", content,"text/html", "utf-8", null);
			}

			@Override
			public void onHttpError(String error) {
				// TODO Auto-generated method stub

			}
		});
	}


}
